00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #ifndef DERENDERSTATES_HPP
00037 #define DERENDERSTATES_HPP
00038
00039 #include "deGlobalTypes.hpp"
00040 #include "deWorld.hpp"
00041
00042
00043 #if defined(DEDRIVER_DLL_EXPORTS) || defined(DESTINY3D_EXPORT_ALL)
00044 # define RENDERSTATE_API extern "C" DEDLL_EXPORT
00045 #elif defined(DESTINY3D_STATIC_LINK)
00046 # define RENDERSTATE_API extern "C"
00047 #else
00048 # define RENDERSTATE_API extern "C" DEDLL_IMPORT
00049 #endif
00050
00051
00052
00053
00054
00055
00056
00057 #define TEXTURESTAGE_COUNT 8
00058
00059
00060
00061
00062 class IdeBitmapProxy;
00063 class IdeRenderTexture;
00064 class IdeRenderMaterial;
00065 class IdeRenderLight;
00066
00067
00068 RENDERSTATE_API deBoolean IdeRenderState_SetDefaultTextureFilters(long MinFilter, long MagFilter, long MipFilter, deBoolean EnableMip);
00069
00070 RENDERSTATE_API long IdeRenderState_GetWOInterfaceID();
00071
00072 RENDERSTATE_API IdeRenderTexture* IdeRenderState_CreateRenderTexture();
00073
00074 RENDERSTATE_API IdeRenderMaterial* IdeRenderState_CreateRenderMaterial();
00075
00076 RENDERSTATE_API IdeRenderLight* IdeRenderState_CreateRenderLight();
00077
00078
00079
00080 DE3D_INTERFACE(IdeRenderState, IdeWorldObject)
00081 {
00082
00083 protected:
00084 virtual ~IdeRenderState() {}
00085 public:
00086 enum Type
00087 {
00088 TYPE_RSTATE = -1,
00089 TYPE_TEXTURE = 0,
00090 TYPE_LIGHT,
00091 TYPE_MATERIAL,
00092 TYPE_COUNT,
00093 TYPE_FORCE_32BIT = 0x7FFFFFFF
00094 };
00095
00096
00097 virtual IdeRenderState::Type GetRSType() const = 0;
00098 virtual void * GetRSInterface(IdeRenderState::Type type) const = 0;
00099
00100
00101
00102 virtual deBoolean Lock() = 0;
00103
00104 virtual deBoolean Unlock() = 0;
00105 };
00106
00107
00108
00109
00110 DE3D_INTERFACE(IdeRenderTexture, IdeRenderState)
00111 {
00112 public:
00113
00114 enum TextureOp
00115 {
00116 TEXTUREOP_INVALID = -1,
00117 TEXTUREOP_DISABLE = 0,
00118
00119
00120 TEXTUREOP_SELECTARG1,
00121 TEXTUREOP_SELECTARG2,
00122
00123
00124 TEXTUREOP_MODULATE,
00125 TEXTUREOP_MODULATE2X,
00126 TEXTUREOP_MODULATE4X,
00127
00128
00129 TEXTUREOP_ADD,
00130 TEXTUREOP_ADDSIGNED,
00131 TEXTUREOP_ADDSIGNED2X,
00132 TEXTUREOP_SUBTRACT,
00133 TEXTUREOP_ADDSMOOTH,
00134
00135
00136 TEXTUREOP_BLENDDIFFUSEALPHA,
00137 TEXTUREOP_BLENDTEXTUREALPHA,
00138 TEXTUREOP_BLENDFACTORALPHA,
00139 TEXTUREOP_BLENDTEXTUREALPHAPM,
00140 TEXTUREOP_BLENDPREVIOUSALPHA,
00141
00142
00143 TEXTUREOP_PREMODULATE,
00144 TEXTUREOP_MODULATEALPHA_ADDCOLOR,
00145 TEXTUREOP_MODULATECOLOR_ADDALPHA,
00146 TEXTUREOP_MODULATEINVALPHA_ADDCOLOR,
00147 TEXTUREOP_MODULATEINVCOLOR_ADDALPHA,
00148
00149
00150 TEXTUREOP_BUMPENVMAP,
00151 TEXTUREOP_BUMPENVMAPLUMINANCE,
00152 TEXTUREOP_DOTPRODUCT3,
00153
00154
00155 TEXTUREOP_MULTIPLYADD,
00156 TEXTUREOP_LERP,
00157
00158 TEXTUREOP_COUNT,
00159 TEXTUREOP_FORCE_32BIT = 0x7FFFFFFF
00160 };
00161
00162
00163 enum TextureArg
00164 {
00165 TEXTUREARG_INVALID = 0,
00166 TEXTUREARG_PREVIOUS = 0x0001,
00167 TEXTUREARG_DIFFUSE = 0x0002,
00168 TEXTUREARG_SPECULAR = 0x0004,
00169 TEXTUREARG_TEXTURE = 0x0010,
00170 TEXTUREARG_TFACTOR = 0x0020,
00171 TEXTUREARG_TEMPREG = 0x0040,
00172
00173
00174 TEXTUREARG_ALPHAREPLICATE = 0x0100,
00175 TEXTUREARG_COMPLEMENT = 0x0200,
00176
00177 TEXTUREARG_COUNT,
00178 TEXTUREARG_FORCE_32BIT = 0x7FFFFFFF
00179 };
00180
00181
00182 enum TextureAddress
00183 {
00184 TEXTUREADDRESS_INVALID = -1,
00185 TEXTUREADDRESS_WRAP = 0,
00186 TEXTUREADDRESS_MIRROR,
00187 TEXTUREADDRESS_CLAMP,
00188 TEXTUREADDRESS_COUNT,
00189 TEXTUREADDRESS_FORCE_32BIT = 0x7FFFFFFF
00190 };
00191
00192
00193 enum TextureFilter
00194 {
00195 TEXTUREFILTER_INVALID = -1,
00196 TEXTUREFILTER_NONE = 0,
00197 TEXTUREFILTER_POINT,
00198 TEXTUREFILTER_LINEAR,
00199 TEXTUREFILTER_ANISOTROPIC,
00200 TEXTUREFILTER_COUNT,
00201 TEXTUREFILTER_FORCE_32BIT = 0x7FFFFFFF
00202 };
00203
00204 enum TextureCoordSource
00205 {
00206 TEXCOORD_INVALID = -1,
00207 TEXCOORD_NOPROCESSING = 0x00000000,
00208 TEXCOORD_VIEWSPACE_NORMAL = 0x00010000,
00209 TEXCOORD_VIEWSPACE_POSITION = 0x00020000,
00210 TEXCOORD_VIEWSPACE_REFLECTIONVECTOR = 0x00030000,
00211 TEXCOORD_FORCE_32BIT = 0x7FFFFFFF
00212 };
00213
00214
00215 protected:
00216 virtual ~IdeRenderTexture() {}
00217 public:
00218
00219 virtual IdeRenderState::Type GetRSType() const = 0;
00220
00221
00222
00223 virtual deBoolean SetColorOperation(long Stage, TextureOp ColorOp) = 0;
00224
00225 virtual deBoolean SetAlphaOperation(long Stage, TextureOp AlphaOp) = 0;
00226
00227 virtual deBoolean SetResultTarget(long Stage, TextureArg Target) = 0;
00228 virtual TextureOp GetColorOperation(long Stage) const = 0;
00229 virtual TextureOp GetAlphaOperation(long Stage) const = 0;
00230 virtual TextureArg GetResultTarget(long Stage) = 0;
00231
00232
00233
00234
00235 virtual deBoolean SetColorArg(long Stage, long ArgNum, TextureArg Arg) = 0;
00236
00237
00238 virtual deBoolean SetAlphaArg(long Stage, long ArgNum, TextureArg Arg) = 0;
00239 virtual TextureArg GetColorArg(long Stage, long ArgNum) const = 0;
00240 virtual TextureArg GetAlphaArg(long Stage, long ArgNum) const = 0;
00241
00242
00243
00244 virtual deBoolean SetBitmap(long Stage, IdeBitmapProxy* Bitmap) = 0;
00245
00246 virtual IdeBitmapProxy*GetBitmap(long Stage) const = 0;
00247
00248
00249
00250 virtual deBoolean SetTextureAddressU(long Stage, TextureAddress Address) = 0;
00251
00252 virtual deBoolean SetTextureAddressV(long Stage, TextureAddress Address) = 0;
00253 virtual TextureAddress GetTextureAddressU(long Stage) const = 0;
00254 virtual TextureAddress GetTextureAddressV(long Stage) const = 0;
00255
00256
00257
00258
00259 virtual deBoolean SetTextureMinFilter(long Stage, TextureFilter Filter) = 0;
00260
00261 virtual deBoolean SetTextureMagFilter(long Stage, TextureFilter Filter) = 0;
00262
00263 virtual deBoolean SetTextureMipFilter(long Stage, TextureFilter Filter) = 0;
00264 virtual TextureFilter GetTextureMinFilter(long Stage) const = 0;
00265 virtual TextureFilter GetTextureMagFilter(long Stage) const = 0;
00266 virtual TextureFilter GetTextureMipFilter(long Stage) const = 0;
00267
00268 virtual deBoolean SetTexCoordSource(long Stage, long SourceStage) = 0;
00269 virtual deBoolean SetTexCoordGen(long Stage, TextureCoordSource SourcePipe, long CopyWrapModeStage = 0) = 0;
00270 virtual deBoolean GetTexCoordSource(long Stage, long &SourceStage, TextureCoordSource &SourceFlags) = 0;
00271 virtual long GetTexCoordSourceCombined(long Stage) = 0;
00272
00273 virtual deBoolean SetTextureProjection(long Stage, deBoolean Enable) = 0;
00274 virtual deBoolean GetTextureProjection(long Stage) = 0;
00275
00276 virtual deBoolean CopyStageSettings(IdeRenderTexture* Target, long SourceStage, long TargetStage) const = 0;
00277 };
00278
00279
00280
00281 DE3D_INTERFACE(IdeRenderMaterial, IdeRenderState)
00282 {
00283 public:
00284 enum MatSource_t
00285 {
00286 MATSOURCE_INVALID = -1,
00287 MATSOURCE_MATERIAL = 0,
00288 MATSOURCE_DIFFUSE,
00289 MATSOURCE_SPECULAR,
00290 MATSOURCE_COUNT,
00291 MATSOURCE_FORCE_32BIT = 0x7FFFFFFF
00292 };
00293 struct MatData
00294 {
00295 deColor AmbientColor;
00296 deColor DiffuseColor;
00297 deColor EmissiveColor;
00298 deColor SpecularColor;
00299 MatSource_t AmbientSource;
00300 MatSource_t DiffuseSource;
00301 MatSource_t SpecularSource;
00302 MatSource_t EmissiveSource;
00303 float Power;
00304 };
00305
00306 protected:
00307 virtual ~IdeRenderMaterial() {}
00308 public:
00309
00310 virtual IdeRenderState::Type GetRSType() const = 0;
00311
00312
00313 virtual deBoolean SetAmbientColor(deColor *AmbientColor) = 0;
00314 virtual deBoolean GetAmbientColor(deColor *AmbientColor) const = 0;
00315
00316 virtual deBoolean SetDiffuseColor(deColor *DiffuseColor) = 0;
00317 virtual deBoolean GetDiffuseColor(deColor *DiffuseColor) const = 0;
00318
00319 virtual deBoolean SetSpecularColor(deColor *SpecularColor) = 0;
00320 virtual deBoolean GetSpecularColor(deColor *SpecularColor) const = 0;
00321
00322 virtual deBoolean SetEmissiveColor(deColor *EmissiveColor) = 0;
00323 virtual deBoolean GetEmissiveColor(deColor *EmissiveColor) const = 0;
00324
00325
00326 virtual deBoolean SetAmbientSource(MatSource_t Source) = 0;
00327 virtual MatSource_t GetAmbientSource() const = 0;
00328
00329 virtual deBoolean SetDiffuseSource(MatSource_t Source) = 0;
00330 virtual MatSource_t GetDiffuseSource() const = 0;
00331
00332 virtual deBoolean SetSpecularSource(MatSource_t Source) = 0;
00333 virtual MatSource_t GetSpecularSource() const = 0;
00334
00335 virtual deBoolean SetEmissiveSource(MatSource_t Source) = 0;
00336 virtual MatSource_t GetEmissiveSource() const = 0;
00337
00338
00339 virtual deBoolean SetSpecularPower(float Power) = 0;
00340 virtual float GetSpecularPower() const = 0;
00341
00342 virtual const MatData* GetAllData() const = 0;
00343 virtual deBoolean SetAllData(const MatData* Data) = 0;
00344 };
00345
00346
00347
00348 DE3D_INTERFACE(IdeRenderLight, IdeRenderState)
00349 {
00350 public:
00351 enum LightType_t
00352 {
00353 LIGHTTYPE_INVALID = -1,
00354 LIGHTTYPE_POINT = 0,
00355 LIGHTTYPE_SPOT,
00356 LIGHTTYPE_DIRECTIONAL,
00357 LIGHTTYPE_COUNT,
00358 LIGHTTYPE_FORCE_32BIT = 0x7FFFFFFF
00359 };
00360 struct LightData
00361 {
00362 LightType_t LightType;
00363 deColor AmbientColor;
00364 deColor DiffuseColor;
00365 deColor SpecularColor;
00366 deVec3f Position;
00367 deVec3f Direction;
00368 deFloat MaxRange;
00369 deFloat FallOff;
00370 deFloat Attenuation[3];
00371 deFloat Theta;
00372 deFloat Phi;
00373 s32 ID;
00374 deBoolean Status;
00375 };
00376
00377
00378 protected:
00379 virtual ~IdeRenderLight() {}
00380 public:
00381
00382 virtual IdeRenderState::Type GetRSType() const = 0;
00383
00384
00385 virtual deBoolean SetLightType(LightType_t Type) = 0;
00386 virtual LightType_t GetLightType() const = 0;
00387
00388
00389 virtual deBoolean SetAmbientColor(deColor *AmbientColor) = 0;
00390 virtual deBoolean GetAmbientColor(deColor *AmbientColor) const = 0;
00391
00392 virtual deBoolean SetDiffuseColor(deColor *DiffuseColor) = 0;
00393 virtual deBoolean GetDiffuseColor(deColor *DiffuseColor) const = 0;
00394
00395 virtual deBoolean SetSpecularColor(deColor *SpecularColor) = 0;
00396 virtual deBoolean GetSpecularColor(deColor *SpecularColor) const = 0;
00397
00398
00399 virtual deBoolean SetPosition(deVertex *Position) = 0;
00400 virtual deBoolean GetPosition(deVertex *Position) const = 0;
00401
00402 virtual deBoolean SetDirection(deVertex *Direction) = 0;
00403 virtual deBoolean GetDirection(deVertex *Direction) const = 0;
00404
00405
00406 virtual deBoolean SetRange(float MaxRange) = 0;
00407 virtual float GetRange() const = 0;
00408
00409 virtual deBoolean SetFallOff(float FallOff) = 0;
00410 virtual float GetFallOff() const = 0;
00411
00412 virtual deBoolean SetAttenuation(long Number, float Value) = 0;
00413 virtual float GetAttenuation(long Number) const = 0;
00414
00415 virtual deBoolean SetTheta(float Theta) = 0;
00416 virtual float GetTheta() const = 0;
00417
00418 virtual deBoolean SetPhi(float Phi) = 0;
00419 virtual float GetPhi() const = 0;
00420
00421
00422 virtual deBoolean SetID(long Number) = 0;
00423 virtual long GetID() const = 0;
00424
00425
00426 virtual deBoolean SetStatus(deBoolean On) = 0;
00427 virtual deBoolean GetStatus() const = 0;
00428
00429 virtual const LightData* GetAllData() const = 0;
00430 virtual deBoolean SetAllData(const LightData* Data) = 0;
00431 };
00432
00433 #endif